package cn.hhs.servlet;


import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;





public class Init extends HttpServlet {

	private static final long serialVersionUID = 8320264695398492462L;
    private static final Log log = LogFactory.getLog(Init.class);


	public void init(ServletConfig config) throws ServletException {
		super.init(config);
        String realPath = config.getServletContext().getRealPath("/"); 
        System.setProperty("WORKDIR", realPath);
        log.info("通过初始化得到项目所在的绝对路径，之后可以通过Constant.WORKREALPATH来访问，项目绝对路径:"+realPath+" ============");
        //设置接口地址
        ServletContext sc = this.getServletContext();
        ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
        ServiceLocator.init(ctx);
        log.info("init ok ");
//        System.out.println(ctx.getBean("carProxy"));
        
	}

}
